#include <cmath>
#include <iostream>
int main() {
    // regard 32 as the max value of w
    /**
     * \param x variable
     * \param w the bits length/size $\ge 8$
    */
    auto A = [](unsigned x, unsigned w) -> unsigned {
        unsigned lastByte = x & 0xff;
        unsigned  Max = (0x00ffffff << w-1)<<1;
        return (x & Max) | lastByte;
    };
    auto B = [](unsigned x, unsigned w) -> unsigned {
        unsigned Max = std::pow(2, w) - std::pow(2, 8);
        return x ^ Max;
    };
    auto C = [](unsigned x, unsigned w) -> unsigned {
        return x|0xff;
    };
    int x=0x87654321,w=32;
    std::cout<<std::hex<<std::showbase;
    std::cout<<"A:"<<A(x,32)<<std::endl;
    std::cout<<"B:"<<B(x,32)<<std::endl;
    std::cout<<"C:"<<C(x,32)<<std::endl;
    return 0;
}